package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MesSordOut;
import com.ruoyi.system.service.IMesSordOutService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 销售出库表Controller
 * 
 * @author ruoyi
 * @date 2024-06-01
 */
@RestController
@RequestMapping("/system/out")
public class MesSordOutController extends BaseController
{
    @Autowired
    private IMesSordOutService mesSordOutService;

    /**
     * 查询销售出库表列表
     */
    @PreAuthorize("@ss.hasPermi('system:out:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesSordOut mesSordOut)
    {
        startPage();
        List<MesSordOut> list = mesSordOutService.selectMesSordOutList(mesSordOut);
        return getDataTable(list);
    }

    /**
     * 导出销售出库表列表
     */
    @PreAuthorize("@ss.hasPermi('system:out:export')")
    @Log(title = "销售出库表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesSordOut mesSordOut)
    {
        List<MesSordOut> list = mesSordOutService.selectMesSordOutList(mesSordOut);
        ExcelUtil<MesSordOut> util = new ExcelUtil<MesSordOut>(MesSordOut.class);
        util.exportExcel(response, list, "销售出库表数据");
    }

    /**
     * 获取销售出库表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:out:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(mesSordOutService.selectMesSordOutById(id));
    }

    /**
     * 新增销售出库表
     */
    @PreAuthorize("@ss.hasPermi('system:out:add')")
    @Log(title = "销售出库表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesSordOut mesSordOut)
    {
        return toAjax(mesSordOutService.insertMesSordOut(mesSordOut));
    }

    /**
     * 修改销售出库表
     */
    @PreAuthorize("@ss.hasPermi('system:out:edit')")
    @Log(title = "销售出库表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesSordOut mesSordOut)
    {
        return toAjax(mesSordOutService.updateMesSordOut(mesSordOut));
    }

    /**
     * 删除销售出库表
     */
    @PreAuthorize("@ss.hasPermi('system:out:remove')")
    @Log(title = "销售出库表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(mesSordOutService.deleteMesSordOutByIds(ids));
    }
}
